<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
		<title>登入</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="/asserts/css/ksd.css" media="all">
		<link rel="stylesheet" href="/asserts/css/login.css" media="all">
		<link rel="stylesheet" href="/plugins/layui/css/modules/laydate/default/laydate.css?v=5.3.1" media="all">
		<link rel="stylesheet" href="/plugins/layui/css/modules/layer/default/layer.css?v=3.5.1" media="all">
		<link rel="stylesheet" href="/plugins/layui/css/modules/code.css?v=2" media="all">
	</head>

	<body data-ext-version="3.1" layadmin-themealias="default">
		<div data-v-7e2550d6="" class="odm_extension image_downloader_wrapper"></div>
		<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
			<div class="layadmin-user-login-main" id="loginapp">
				<div class="layadmin-user-login-box layadmin-user-login-header">
					<h2>登录</h2>
					<p></p>
				</div>
				<div class="layadmin-user-login-box layadmin-user-login-body layui-form">
					<div class="layui-form-item">
						<label class="layadmin-user-login-icon layui-icon layui-icon-username" ></label>
						<input type="text" id="username" v-model="user.username" value="admin"  lay-verify="required" placeholder="用户名" class="layui-input">
					</div>
					<div class="layui-form-item">
						<label class="layadmin-user-login-icon layui-icon layui-icon-password" ></label>
						<input type="password" id="password" v-model="user.password" value="admin"  lay-verify="required" placeholder="密码" class="layui-input">
					</div>
					<div class="layui-form-item" style="margin-bottom: 20px;">
						<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
						<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>记住密码</span><i class="layui-icon layui-icon-ok"></i></div>
						<a href="forget.html" class="layadmin-user-jump-change cof" style="margin-top: 7px;">忘记密码？</a>
					</div>
					<div class="layui-form-item">
						<button class="layui-btn layui-btn-fluid" lay-submit="" @click="logined" lay-filter="LAY-user-login-submit">登 入</button>
					</div>
				</div>
			</div>

			<div class="layui-trans layadmin-user-login-footer">
				<p>© All Rights Reserved</p>
			</div>
		</div>
		<div class="bg"></div>
		<script src="/asserts/js/vue.min.js"></script>
		<script src="/asserts/js/axios.min.js"></script>
		<script>
			document.onkeydown = function (e) { // 回车提交表单
				// 兼容FF和IE和Opera
				var theEvent = window.event || e;
				var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
				if (code == 13) {
					vue.logined();
				}
			}
			var vue = new Vue({
				el: "#loginapp",
				data: {
					user: {
						username: "yykk",
						password: "123456"
					}
				},
				methods: {
					logined: function () {
						var that= this;
						if(!that.user.username){
							alert("请输入账号")
							document.getElementById("username").focus();
							return;
						}

						if(!that.user.password){
							alert("请输入密码")
							document.getElementById("password").focus();
							return;
						}

						axios.post("/admin/logined",this.user).then(function(res){
							if(res.data.code == 200){
								window.location.href = "/admin/index";
							}else{
								alert(res.data.message);
								that.user.password = "";
								document.getElementById("password").focus();
							}
						})
					}
				}
			})
		</script>
	</body>
</html>